// 1.定义仓库
const store = {
  namespaced: true,
  state: {
    // 将本地存储的token值保存到vuex的仓库中
    token: window.localStorage.getItem('token'),
    // 存储刷新token
    refreshToken: window.localStorage.getItem('refresh-token')
  },
  mutations: {
    setToken (state, token, refreshToken) {
      // 将传输进来的token赋值给仓库
      state.token = token
      // 存刷新token
      state.refreshToken = refreshToken
      // 将token存储到本地
      window.localStorage.setItem('token', token)
      window.localStorage.setItem('refresh-token', refreshToken)
    }
  }
}
export default store
